package Daemon;

public class Demo {
	
	public static void main(String[] args) {
		deamonTest();
		Test1();
		Test2();
	}

	public static void deamonTest() {
		final long begin = System.currentTimeMillis();
		Runnable run2 = new Runnable() {
			public void run() {
				while (true) {
					try {
						Thread.sleep(1000);
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
					long end = System.currentTimeMillis();
					System.out.println("时间:" + (end - begin) / 1000);
				}
			}
		};

		Thread deamon1 = new Thread(run2);
		deamon1.setDaemon(true);

		deamon1.start();
	}

	public static void Test1() {
		Runnable run1 = new Runnable() {
			public void run() {
				DeameThread d = new DeameThread();
				d.start();
			}
		};
		Thread t1 = new Thread(run1);
		t1.start();
		System.out.println("测试结束####################");
	}
	
	public static void Test2() {
		Runnable run1 = new Runnable() {
			public void run() {
				DeameThread d = new DeameThread();
				d.start();
			}
		};
		Thread t1 = new Thread(run1);
		t1.start();
		System.out.println("测试结束####################");
	}
}
